package red.lixiang.controller;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import red.lixiang.dao.PostDAO;
import red.lixiang.model.BaseInfo;
import red.lixiang.model.PostArticle;
import red.lixiang.service.ListService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import static red.lixiang.base.APPCONST.INDEX_IMAGE;

@Controller
public class BlogController {

    private    final Logger logger = Logger.getLogger(BlogController.class.getName());


    @Autowired
    private PostDAO postDAO;

    /**
     * @return
     */
    @GetMapping("/blog/blogDetail")
    @ResponseBody
    public String showHome(@RequestParam Integer id){
        PostArticle postArticle = new PostArticle();
        postArticle.setId(id);
        List<PostArticle> articleList = postDAO.getPostArticle(postArticle);

        return JSON.toJSONString(articleList.get(0));
    }



}
